<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="description" content="轻量级，高可靠，易学习的 java 并发管理工具。">
    <meta name="keywords" content="java, PDConcurrent, fybug, java lib, concurrent">
    <title>PDConcurrent</title>
    <link rel="icon" href="./static/img/PDConcurrent.png">
</head>
<body>

<!-- 顶栏 -->
<header></header>

<!-- 内容部分 -->
<section class="grid-y grid-padding-x off-canvas-content" data-off-canvas-content>
    <!-- 标题区 -->
    <tit class="shadow cell grid-y align-center">
        <div class="cell grid-x text-center padding-vertical-2 padding-horizontal-2">
            <!-- 标题 -->
            <div class="cell">

                <h1 class="cell font-bold font-wide">PDConcurrent</h1>
                <!-- 简介 -->
                <h6 class="margin-vertical-1 cell">轻量级，高可靠，易学习的 java 并发管理工具。</h6>
            </div>

            <!-- 按钮 -->
            <div class="cell button-group no-gaps margin-top-1 align-center">
                <a class="button padding-vertical-1 padding-horizontal-2" target="_blank"
                   href="https://gitee.com/PatternDirClean/PDConcurrent"
                   style="border-radius: .5rem 0 0 .5rem">
                    <h5 class="margin-bottom-0">gitee</h5></a>
                <a class="button padding-vertical-1 padding-horizontal-2" target="_blank"
                   href="https://github.com/PatternDirClean/PDConcurrent"
                   style="border-radius: 0 .5rem .5rem 0">
                    <h5 class="margin-0">github</h5></a>
            </div>
        </div>
    </tit>

    <!-- 特性介绍 -->
    <section class="cell grid-x align-center grid-container padding-vertical-3" id="characteristic">
        <div class="cell large-3 medium-6 padding-1 align-top">
            <div class="grid-x">
                <i class="fa fa-cube large-12 medium-shrink small-12"></i>
                <p class="large-12 medium-auto small-12">轻量级</p>
            </div>
            <p>仅不足 100kb 的 .jar 包。</p>
        </div>
        <div class="cell large-3 medium-6 padding-1 align-top">
            <div class="grid-x">
                <i class="fa fa-diamond large-12 medium-shrink small-12"></i>
                <p class="large-12 medium-auto small-12">可靠</p>
            </div>
            <p>使用接口注入的方式管理代码。<br/>内部并发域不对外暴露，更易管理且稳定。</p>
        </div>
        <div class="cell large-3 medium-6 padding-1 align-top">
            <div class="grid-x">
                <i class="fa fa-tachometer large-12 medium-shrink small-12"></i>
                <p class="large-12 medium-auto small-12">高性能</p>
            </div>
            <p>使用 java 原生并发管理作为控制的底层，效率更高。</p>
        </div>
        <div class="cell large-3 medium-6 padding-1 align-top">
            <div class="grid-x">
                <i class="fa fa-leaf large-12 medium-shrink small-12"></i>
                <p class="large-12 medium-auto small-12">易学习</p>
            </div>
            <p>所有实现均采用一个标准接口，且根据使用的 java 并发工具实现变形。</p>
        </div>
        <hr class="cell"/>
    </section>

    <!-- 使用示例 -->
    <section class="cell grid-x grid-container jieshao" id="foundationuser">
        <h3 class="cell"><i class="fa fa-file-text-o" style="font-size: 2.2rem"></i> 统一标准</h3>
        <p class="cell">如果你已经熟悉 java 的多线程管理，尤其是 ReentrantReadWriteLock 读写锁的话你会更容易学会本工具。</p>
        <p class="cell">本工具采用读写锁标准，无论内部实现如何，外部接口均提供 **read, **write 方法区分读锁并发域和写锁并发域</p>
        <div class="cell small-12 large-10 align-center grid-y" margin="horizontal">
            <h4 class="cell"><b>> ></b> 基础使用示例</h4>
            <div class="cell grid-x">
                <div class="cell padding-1 shrink hide-for-small-only"></div>
                <pre class="cell auto"><code class="code-block width-100"><span
                        style="color: #09d9d2">// 尝试申请读锁</span>
<span style="color:#fff;">SyLock.newObjLock</span><span style="color: #f6b5e7">()</span><span
                            style="color:#fff;">.read</span><span
                            style="color: #f6b5e7">(()</span><span
                            style="color: #fff"> -> </span><span style="color: #f6b5e7">{</span>
    <span style="color: #09d9d2">// 并发域代码内容</span>
    <span style="color: #ff7561">[</span><span style="color: #b5c0f6">return</span> <span
                            style="color:#fff;">null</span><span
                            style="color: #f6b5e7">;</span><span
                            style="color: #ff7561">]?</span> <span
                            style="color: #09d9d2">// 可选择是否返回</span>
<span style="color: #f6b5e7">})</span><span style="color: #fff">;</span>

<span style="color: #09d9d2">// 尝试申请写锁</span>
<span style="color:#fff;">SyLock.newObjLock</span><span style="color: #f6b5e7">()</span><span
                            style="color:#fff;">.write</span><span

                            style="color: #f6b5e7">(()</span><span
                            style="color: #fff"> -> </span><span style="color: #f6b5e7">{</span>
    <span style="color: #ff7561">[</span><span style="color: #b5c0f6">return</span> <span
                            style="color:#fff;">null</span><span
                            style="color: #f6b5e7">;</span><span
                            style="color: #ff7561">]?</span>
<span style="color: #f6b5e7">})</span><span style="color: #fff">;</span></code></pre>
                <div class="cell padding-1 shrink hide-for-small-only"></div>
            </div>
        </div>
        <blockquote class="cell">SyLock 为该工具的标准接口，同时包含不同实现的基础工厂方法。</blockquote>
        <hr class="cell"/>
    </section>

    <!-- 变形示例 -->
    <section class="cell grid-x grid-container jieshao" id="deform">
        <h3 class="cell"><i class="fa fa-code-fork" style="font-size: 2.4rem"></i> 锁变形示例</h3>
        <p class="cell">可通过接口的工厂方法实例化内部采用不同实现的锁。</p>
        <div class="cell small-12 large-10 align-center grid-y" margin="horizontal">
            <h4 class="cell"><b>> ></b> synchronized 锁</h4>
            <div class="cell grid-x">
                <div class="cell padding-1 shrink hide-for-small-only"></div>
                <pre class="cell auto"><code class="code-block width-100"><span
                        style="color: #09d9d2">// 使用</span>
<span style="color:#fff;">SyLock.newObjLock</span><span style="color: #f6b5e7">()</span><span
                            style="color:#fff;">.read</span><span
                            style="color: #f6b5e7">(()</span><span
                            style="color: #fff"> -> </span><span style="color: #f6b5e7">{</span>
    <span style="color: #09d9d2">// 并发域代码内容</span>
<span style="color: #f6b5e7">})</span><span style="color: #fff">;</span>

<span style="color: #09d9d2">// 不使用</span>
<span style="color: #b5c0f6">synchronized</span> <span style="color: #f6b5e7">(</span> <span
                            style="color: #b5c0f6">new</span> <span
                            style="color:#fff;">Object</span><span
                            style="color: #f6b5e7">() ){</span>
    <span style="color: #09d9d2">// 并发域代码内容</span>
<span style="color: #f6b5e7">}</span></code></pre>
                <div class="cell padding-1 shrink hide-for-small-only"></div>
            </div>

            <h4 class="cell"><b>> ></b> ReentrantLock 锁</h4>
            <div class="cell grid-x">
                <div class="cell padding-1 shrink hide-for-small-only"></div>
                <pre class="cell auto"><code class="code-block width-100"><span
                        style="color: #09d9d2">// 使用</span>
<span style="color:#fff;">SyLock.newReLock</span><span style="color: #f6b5e7">()</span><span
                            style="color:#fff;">.read</span><span
                            style="color: #f6b5e7">(()</span><span
                            style="color: #fff"> -> </span><span style="color: #f6b5e7">{</span>
    <span style="color: #09d9d2">// 并发域代码内容</span>
<span style="color: #f6b5e7">})</span><span style="color: #fff">;</span>

<span style="color: #09d9d2">// 不使用</span>
<span style="color:#fff;">ReentrantLock</span> <span style="color: #b5c0f6">lock</span> <span
                            style="color:#fff;">=</span> <span
                            style="color: #b5c0f6">new</span> <span style="color:#fff;">ReentrantLock</span><span
                            style="color: #f6b5e7">()</span><span style="color:#fff;">;</span>
<span style="color: #b5c0f6">try</span> <span style="color: #f6b5e7">{</span>
    <span style="color: #b5c0f6">lock</span><span style="color: #fff">.lock</span><span
                            style="color: #f6b5e7">()</span><span style="color: #fff">;</span>
    <span style="color: #09d9d2">// 并发域代码内容</span>
<span style="color: #f6b5e7">}</span> <span style="color: #b5c0f6">finally</span> <span
                            style="color: #f6b5e7">{</span>
    <span style="color: #b5c0f6">lock</span><span style="color:#fff;">.unlock</span><span
                            style="color: #f6b5e7">()</span><span style="color:#ffffff;">;</span>
<span style="color: #f6b5e7">}</span></code></pre>
                <div class="cell padding-1 shrink hide-for-small-only"></div>
            </div>

            <h4 class="cell"><b>> ></b> ReadWriteLock 锁</h4>
            <div class="cell grid-x">
                <div class="cell padding-1 shrink hide-for-small-only"></div>
                <pre class="cell auto"><code class="code-block width-100"><span
                        style="color: #09d9d2">// 使用</span>
<span style="color:#fff;">SyLock.newRWLock</span><span style="color: #f6b5e7">()</span><span
                            style="color:#fff;">.read</span><span
                            style="color: #f6b5e7">(()</span><span
                            style="color: #fff"> -> </span><span style="color: #f6b5e7">{</span>
    <span style="color: #09d9d2">// 并发域代码内容</span>
<span style="color: #f6b5e7">})</span><span style="color: #fff">;</span>

<span style="color: #09d9d2">// 不使用</span>
<span style="color:#fff;">ReadWriteLock</span> <span style="color: #b5c0f6">lock</span> <span
                            style="color:#fff;">=</span> <span
                            style="color: #b5c0f6">new</span> <span style="color:#fff;">ReentrantReadWriteLock</span><span
                            style="color: #f6b5e7">()</span><span style="color:#fff;">;</span>
<span style="color: #b5c0f6">try</span> <span style="color: #f6b5e7">{</span>
    <span style="color: #b5c0f6">lock</span><span style="color: #fff">.readLock</span><span
                            style="color: #f6b5e7">()</span><span
                            style="color: #fff">.lock</span><span
                            style="color: #f6b5e7">()</span><span style="color: #fff">;</span>
    <span style="color: #09d9d2">// 并发域代码内容</span>
<span style="color: #f6b5e7">}</span> <span style="color: #b5c0f6">finally</span> <span
                            style="color: #f6b5e7">{</span>
    <span style="color: #b5c0f6">lock</span><span style="color: #fff">.readLock</span><span
                            style="color: #f6b5e7">()</span><span style="color:#fff;">.unlock</span><span
                            style="color: #f6b5e7">()</span><span style="color:#ffffff;">;</span>
<span style="color: #f6b5e7">}</span></code></pre>
                <div class="cell padding-1 shrink hide-for-small-only"></div>
            </div>
        </div>
        <hr class="cell"/>
    </section>

    <!-- 使用方法 -->
    <section class="cell grid-x grid-container jieshao" id="input">
        <h3 class="cell"><i class="fa fa-code" style="font-size: 2.3rem"></i> 使用</h3>
        <p class="cell">请导入其 .jar 文件,前往 github/gitee 发行版 或 项目的 jar 文件夹下可以找到<br/>将 jar 包追加到项目依赖中即可使用。
        </p>
        <p>发行版中可以看到全部版本<br/>项目下的 jar 文件夹是当前最新的每夜版</p>
    </section>

</section>

<footer class="grid-y text-center align-center">
    <div class="cell grid-x grid-margin-x align-center">
        <!-- 项目位置连接 -->
        <div class="cell medium-shrink small-12 grid-y align-center">
            <h5 class="cell"><u><a
                    href="https://github.com/fybug">github</a></u>
                / <u><a
                        href="https://gitee.com/fybug">gitee</a></u> @ fybug</h5>
        </div>
        <!-- 说明 -->
        <div class="cell shrink grid-y align-center">
            <p class="cell margin-0">PDConcurrent by 2020</p>
            <p class="cell margin-0">web code of the 2020</p>
        </div>
    </div>
    <hr class="cell margin-bottom-0"/>
    <h4 class="margin-top-1">使用下列项目搭建</h4>
    <div class="cell grid-x align-center text-center">
        <p class="cell large-2 medium-3">Foundation v6.6.3</p>
        <p class="cell large-2 medium-3">font-awesome v4.7.0</p>
        <p class="cell large-2 medium-3"><u><a href="https://gitee.com/fybug/aout.ass">aout.ass
            v0.0.1</a></u></p>
        <p class="cell large-2 medium-3"><u><a href="https://gitee.com/fybug/vhannels">vhannels
            v0.0.1</a></u></p>
    </div>
</footer>

</body>
</html>